package com.example.yskjproject.view.dialog;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.example.yskjproject.R;
import com.example.yskjproject.content.EventContent;
import com.example.yskjproject.event.EventMessage;
import com.example.yskjproject.http.Urls;
import com.example.yskjproject.http.callback.JsonCallback;
import com.example.yskjproject.model.LzyResponse;
import com.example.yskjproject.model.QRBindWxModel;
import com.example.yskjproject.model.WxScanCodeModel;
import com.example.yskjproject.utils.EventBusUtil;
import com.example.yskjproject.utils.SpCashUtils;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * WXCodeDialog
 * <p>
 * 作者：zx
 * 创建时间：2024/5/18
 */
public class KfDialog extends Dialog {

    private Context context;
    String type;

    public KfDialog(@NonNull Context context, String type) {
        super(context);
        setContentView(R.layout.kf_dialog);
        this.context = context;
        this.type = type;
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        if (window != null) {
            WindowManager.LayoutParams layoutParams = window.getAttributes();
            layoutParams.width = (int) (getContext().getResources().getDisplayMetrics().widthPixels * 0.8); // 设置宽度为500dp
            layoutParams.height = (int) (getContext().getResources().getDisplayMetrics().heightPixels * 0.28); // 设置高度为300dp
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            window.setAttributes(layoutParams);
        }
        AppCompatTextView contentStr = findViewById(R.id.content);
        AppCompatImageView imageView = findViewById(R.id.img_code);
        AppCompatTextView top_title = findViewById(R.id.top_title);

        AppCompatTextView version_content = findViewById(R.id.version_content);



        AppCompatImageView img_colose = findViewById(R.id.img_colose);
        img_colose.setOnClickListener(close -> dismiss());
        switch (type) {
            case "kf":
                version_content.setVisibility(View.GONE);
                top_title.setText("客服");
//                Glide.with(context).load(wxScanCodeModel.getImg_url())
//                        .apply(RequestOptions.bitmapTransform(new RoundedCorners(40)))//圆角半径
//                        .into(imageView);
                contentStr.setText("请联系官方客服");
                break;
            case "gy":
                top_title.setText("关于");
                version_content.setVisibility(View.VISIBLE);
                contentStr.setVisibility(View.GONE);
                imageView.setVisibility(View.GONE);
                version_content.setText("软件版本号:V 1.0.0");
                break;
        }
    }
}
